<%@page import="edu.ncsu.csc.itrust.action.ViewLabTechProceduresAction"%>
<%@page import="edu.ncsu.csc.itrust.beans.LabProcedureBean"%>
<%@page import="java.util.List"%>
<%@page import="edu.ncsu.csc.itrust.dao.mysql.PersonnelDAO"%>

<%@include file="/global.jsp"%>

<%
pageTitle = "iTrust - LT - In-Transit List";
%>

<%@include file="/header.jsp"%>

<table cellpadding="1" cellspacing="1">
	<% 
	String lpid = request.getParameter("ID");
	
	ViewLabTechProceduresAction action = new ViewLabTechProceduresAction(prodDAO, loggedInMID.longValue());
			
	if(lpid != null && !"".equals(lpid) ){
		action.updateReceived(new Long(lpid));
		loggingAction.logEvent(TransactionType.LAB_UPDATE_RECEIVED, loggedInMID.longValue(), 0L, "Lab Proc ID: "+lpid);	
	}
	
	List<LabProcedureBean> lpBeans = action.getInTransit();
%>
	<div align=center>
	<table class="fTable" align="center">
		<tr>
			<th colspan="8">In-Transit Laboratory Procedures</th>
		</tr>
		<tr class="subHeader">
			<td>LOINC Code</td>
			<td>Priority</td>
			<td>Status</td>
			<td>Assigned Tech</td>
			<td>Commentary</td>
			<td>Results</td>
			<td style="width: 60px;">Updated Date</td>
			<td>Action</td>
		</tr>
		<%if(lpBeans.size()==0){ %>
		<tr>
			<td colspan="8" style="text-align: center;">No In-Transit Lab
			Procedures</td>
		</tr>
		<%} else { %>
		<%for(LabProcedureBean labproc : lpBeans){ %>
		<% String ltname = "Unassigned"; %>
		<% if(labproc.getLtID() != 0){ %>
		<% ltname = prodDAO.getPersonnelDAO().getName(labproc.getLtID()); %>
		<% } %>
		<tr>
			<td align=center><%= StringEscapeUtils.escapeHtml("" + (labproc.getLoinc())) %></td>
			<td align=center><%= StringEscapeUtils.escapeHtml("" + (labproc.getPriority())) %></td>
			<td align=center><%= StringEscapeUtils.escapeHtml("" + (labproc.getStatus())) %></td>
			<td align=center><%= StringEscapeUtils.escapeHtml("" + (ltname)) %></td>
			<td align=center><%= StringEscapeUtils.escapeHtml("" + (labproc.getCommentary())) %></td>
			<td align=center><%= StringEscapeUtils.escapeHtml("" + (labproc.getResults())) %></td>
			<td align=center><%= StringEscapeUtils.escapeHtml("" + (labproc.getTimestamp())) %></td>
			<td><a href=inTransit.jsp?ID= <%=labproc.getProcedureID()%>>Received</a>
			</td>
		</tr>
		<%} %>
		<%} %>
	</table>
	</div>
</table>

<%@include file="/footer.jsp"%>